home *** CD-ROM | disk | FTP | other *** search
- unit ActionApp2U;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ActnList, ImgList, ComCtrls, ToolWin, Menus, Buttons;
-
- type
- TForm1 = class(TForm)
- edtEntry: TEdit;
- Label1: TLabel;
- lstEntries: TListBox;
- btnAddString: TBitBtn;
- ActionList: TActionList;
- ImageList: TImageList;
- actAddString: TAction;
- MainMenu: TMainMenu;
- File1: TMenuItem;
- AddString1: TMenuItem;
- N1: TMenuItem;
- Exit1: TMenuItem;
- PopupMenu: TPopupMenu;
- AddString2: TMenuItem;
- ToolBar1: TToolBar;
- ToolButton1: TToolButton;
- procedure actAddStringExecute(Sender: TObject);
- procedure actAddStringUpdate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.actAddStringExecute(Sender: TObject);
- begin
- lstEntries.Items.Add( Trim( edtEntry.Text ) );
- //Give focus back to edit
- edtEntry.SetFocus;
- //Highlight edit's contents so it can be replaced by overtyping
- edtEntry.SelectAll;
- end;
-
- procedure TForm1.actAddStringUpdate(Sender: TObject);
- begin
- (Sender as TAction).Enabled :=
- ( Length( Trim( edtEntry.Text ) ) > 0 ) and
- ( lstEntries.Items.IndexOf( Trim( edtEntry.Text ) ) = -1 )
- end;
-
- end.
-